/*
 * @Author: 姚潘涛
 * @Date: 2024-04-08 20:36:40
 * @LastEditors: 姚潘涛
 * @LastEditTime: 2024-04-09 18:35:26
 * @FilePath:
 * /xict_ws/src/xcmg-intelligent-cockpit-three/src/xict_ui/tests/xict_ui/test_driver.cpp
 * @Description:
 *
 * Copyright (c) 2024 by pandaman, All Rights Reserved.
 */

#include "xict_proto/sensor/can.pb.h"
#include "xict_proto/sensor/image.pb.h"
#include "xict_ui_common/utils/msgsbridge.h"
#include <QThread>
#include <ecal/ecal.h>
#include <ecal/msg/protobuf/publisher.h>

int main(int argc, char* argv[]) {
    eCAL::Initialize(argc, argv, "test driver");
    eCAL::protobuf::CPublisher<xcmg_proto::OpencvImage> img_pub(
        "front_switcher");

    QImage image = QImage("/home/wq/qt_workspace/xcmg-remote-control-ui/src/"
                          "xict_ui_core/resources/imgs/bg_img.png");
    std::cout << image.width() << "  " << image.height() << " "
              << image.format() << std::endl;

    xcmg_proto::OpencvImage msg = xict_ui_common::QImage2ProtoRaw(image);

    while (eCAL::Ok()) {
        // Let the user input a message
        //        std::cout << "Type the message you want to send: ";
        //        std::string message;
        //        std::getline(std::cin, message);

        img_pub.Send(msg);
        std::cout << "Img size" << msg.cols() << " " << msg.rows() << std::endl;
        //        std::cout << "Sent message!" << std::endl << std::endl;
        QThread::msleep(200);
    }

    // finalize eCAL API
    eCAL::Finalize();
}
